The HiPerCopS IDE Standard Library is distributed with each copy of the IDE source code. The Standard Library contains definitions for all of the elements, cells, and modules that are considered to be essential building blocks for most applications. 

\section{Elements}

The element directory of the Standard Library contains all of the elements listed in Table \ref{table:element_types}. The truth table for each of these elements is listed here in Table \ref{table:standard_elements}. 

The `Ctc', `add', and `empty' elements are also included in the Standard Library. The `Ctc' element is used in multiply-accumulate cells when two's complement numbers are involved. The `add' element is used in an unsigned addition cell, and the `empty' cell returns `00' no matter what the input is.

\begin{table}
\caption{Elements in the Standard Library.}
\centering
\begin{tabular}{|c||c|c|c|c|c|c|c|c|c|c|c|}
\hline $\alpha\beta\gamma\delta$ & A & B & C & D & E & F & G & H & Ctc & add & empty \\ 
\hline
\hline 0000 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 \\ 
\hline 0001 & 01 & 01 & 01 & 01 & 01 & 11 & 11 & 11 & 11 & 01 & 00 \\ 
\hline 0010 & 01 & 01 & 11 & 11 & 11 & 01 & 01 & 11 & 01 & 01 & 00 \\ 
\hline 0011 & 10 & 10 & 00 & 00 & 00 & 00 & 00 & 10 & 00 & 10 & 00 \\ 
\hline 0100 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 11 & 01 & 00 \\ 
\hline 0101 & 01 & 01 & 01 & 01 & 01 & 11 & 11 & 11 & 01 & 10 & 00 \\ 
\hline 0110 & 01 & 01 & 11 & 11 & 11 & 01 & 01 & 11 & 00 & 10 & 00 \\ 
\hline 0111 & 10 & 10 & 00 & 00 & 00 & 00 & 00 & 10 & 00 & 11 & 00 \\ 
\hline 1000 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 00 & 11 & 00 & 00 \\ 
\hline 1001 & 01 & 01 & 01 & 01 & 01 & 11 & 11 & 11 & 01 & 01 & 00 \\ 
\hline 1010 & 01 & 01 & 11 & 11 & 11 & 01 & 01 & 11 & 00 & 01 & 00 \\ 
\hline 1011 & 10 & 10 & 00 & 00 & 00 & 00 & 00 & 10 & 11 & 10 & 00 \\ 
\hline 1100 & 01 & 01 & 11 & 11 & 11 & 11 & 11 & 01 & 11 & 01 & 00 \\ 
\hline 1101 & 10 & 10 & 00 & 00 & 00 & 10 & 10 & 00 & 10 & 10 & 00 \\ 
\hline 1110 & 10 & 10 & 10 & 10 & 10 & 00 & 00 & 00 & 00 & 10 & 00 \\ 
\hline 1111 & 11 & 11 & 11 & 11 & 11 & 11 & 11 & 11 & 11 & 11 & 00 \\ 
\hline 
\end{tabular}
\label{table:standard_elements}
\end{table}

\section{Cells}

Cells of type `A', `B', `C', `D', `E', `F', and `H' all perform the multiply-accumulate operation, $y = (a \times b) + c + d$. Inputs $a$, $b$, $c$, and $d$ are each four bits long and are in either unsigned or two's complement form, depending on the cell. 

In the following descriptions, the four entries listed as the input format correspond to the four cell inputs. A $+$ indicates that the input is in unsigned form, while a $-$ indicates that the input is in two's complement form. 

The two entries of the output format represent the upper and lower halves of the cell output. These halves can also be in either unsigned or two's complement form, represented by the $+$ and $-$ symbols, respectively.

\subsubsection{A}

\begin{quote}
Input format: $(+, +, +, +)$ \\
Output format: $(+, +)$
\end{quote}

\begin{center}
\begin{tabular}{|c|c|c|c|}
\hline A & A & A & A \\ 
\hline A & A & A & A \\ 
\hline A & A & A & A \\ 
\hline A & A & A & A \\ 
\hline 
\end{tabular} 
\end{center}

\subsubsection{B}

\begin{quote}
Input format: $(-, +, -, -)$ \\
Output format: $(-, -)$
\end{quote}

\begin{center}
\begin{tabular}{|c|c|c|c|}
\hline B & A & A & A \\ 
\hline D & Ctc & A & A \\ 
\hline D & A & Ctc & A \\ 
\hline D & A & A & Ctc \\ 
\hline 
\end{tabular} 
\end{center}

\subsubsection{C}

\begin{quote}
Input format: $(+, +, +, -)$ \\
Output format: $(+, -)$
\end{quote}

\begin{center}
\begin{tabular}{|c|c|c|c|}
\hline C & A & A & A \\ 
\hline A & Ctc & A & A \\ 
\hline A & A & Ctc & C \\ 
\hline A & A & A & Ctc \\ 
\hline 
\end{tabular} 
\end{center}

\subsubsection{D}

\begin{quote}
Input format: $(-, +, -, +)$ \\
Output format: $(-, +)$
\end{quote}

\begin{center}
\begin{tabular}{|c|c|c|c|}
\hline D & A & A & A \\ 
\hline D & A & A & A \\ 
\hline D & A & A & A \\ 
\hline D & A & A & A \\ 
\hline 
\end{tabular} 
\end{center}

\subsubsection{E}

\begin{quote}
Input format: $(+, -, -, +)$ \\
Output format: $(-, +)$
\end{quote}

\begin{center}
\begin{tabular}{|c|c|c|c|}
\hline G & A & A & A \\ 
\hline A & Ctc & A & A \\ 
\hline A & A & Ctc & A \\ 
\hline F & F & F & E \\ 
\hline 
\end{tabular} 
\end{center}

\subsubsection{F}

\begin{quote}
Input format: $(+, -, +, -)$ \\
Output format: $(-, +)$
\end{quote}

\begin{center}
\begin{tabular}{|c|c|c|c|}
\hline C & A & A & A \\ 
\hline A & Ctc & A & A \\ 
\hline A & A & Ctc & A \\ 
\hline F & F & F & E \\ 
\hline 
\end{tabular} 
\end{center}

\subsubsection{H}

\begin{quote}
Input format: $(-, -, -, -)$ \\
Output format: $(-, +)$
\end{quote}

\begin{center}
\begin{tabular}{|c|c|c|c|}
\hline B & A & A & A \\ 
\hline D & Ctc & A & A \\ 
\hline D & A & Ctc & A \\ 
\hline H & F & F & E \\ 
\hline 
\end{tabular} 
\end{center}

\subsubsection{O}

The type `O' cell is simply an empty cell. Its elements' lookup tables are filled with zeros. The type O cell can be used to represent an unconfigured cell.

\begin{center}
\begin{tabular}{|c|c|c|c|}
\hline empty & empty & empty & empty \\ 
\hline empty & empty & empty & empty \\ 
\hline empty & empty & empty & empty \\ 
\hline empty & empty & empty & empty \\ 
\hline 
\end{tabular} 
\end{center}

\subsubsection{add}

The `add' cell is used to perform unsigned addition. To see how it is used, consider the adder module in the next section.

\begin{center}
\begin{tabular}{|c|c|c|c|}
\hline A & A & A & add \\ 
\hline A & A & A & add \\ 
\hline A & A & A & add \\ 
\hline A & A & A & add \\ 
\hline 
\end{tabular} 
\end{center}

\section{Modules}

\subsubsection{Add}

The add module is a 32-bit unsigned adder, built using cell types A and add.

{\tt
\begin{singlespace}
\lstset{numbers=left, numbersep=20pt, frame=single, }
\lstinputlisting{../lib/module/add.module}
\end{singlespace}
}

\subsubsection{MAC}

The two's complement MAC module performs the multiply-accumulate function, $Y = (a \times b) + c + d$, on binary strings in two's complement format. It utilizes all of the MAC cells in the Standard Library.

{\tt
\begin{singlespace}
\lstset{numbers=left, numbersep=20pt, frame=single, }
\lstinputlisting{../lib/module/mac.module}
\end{singlespace}
}

\section{Repository}

Over time, the Standard Library may grow to include more entries. To allow users to update their library files, the Standard Library is stored in an online repository. This repository can be accessed using following Subversion command:

\begin{quote}
{\tt svn checkout http://hipercops-washington.googlecode.com/svn/trunk/lib standardlib}
\end{quote}

This will download the latest versions of all of the Standard Library entries and store them in a directory named {\tt standardlib}. For more information on Subversion, see Appendix C.